//
//  HMNetWorkTool.m
//  SinaWeiBo
//
//  Created by WGP on 16/4/10.
//  Copyright © 2016年 WGP. All rights reserved.
//

#import "HMNetWorkTool.h"

@implementation HMNetWorkTool


+(instancetype)sharedNetWorkTool
{
    static HMNetWorkTool *instance = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        instance = [[HMNetWorkTool alloc] init];
        
    instance.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript",@"text/plain", nil];
        
    });
    return instance;
}

-(NSError *)errorWith:(HMNetWorkError)errorType
{
    _errorType = errorType;
    return [[NSError alloc] initWithDomain:@"cn.ithei.net" code:errorType userInfo:@{@"errorDescription":[self errorDescription]}];
}


-(NSString *)errorDescription
{
    if (_errorType == HMNetWorkErrorOfAccessTokenEmpty)
    {
        return @"Access_token为空";
    }else if(_errorType == HMNetWorkErrorOfUidEmpty)
    {
        return @"用户uid为空";
    }else
    {
        return @"重复加载微博数据";
    }
}

@end
